import re
import requests
from bs4 import BeautifulSoup
#str = 'id:2417315668,telephone number:123456789101'
# #findall:匹配字符串中所有的符合正则的内容
# print(re.findall(r"\d+", str))
#
# ##常用##finditer:匹配字符串中所有的内容[返回的是迭代器]
# it = re.finditer(r"\d+",str)
# for i in it:
#     print(i)
#     print(i.group())
#
# #search:找到一个结果就返
# s = re.search(r"\d+",str)
# print(s.group())
# print(s.group())
#
# #match:从字符串开头匹配,如果开头不符合正则表达式就报错
# m = re.match(r"\d+",str)
# print(m.group())

# #预加载正则表达式compile:可以多次使用
# obj = re.compile(r"\d+")
# ret = obj.finditer(str)
# for i in ret:
#     print(i.group())
# str1 = 'hello,14750'
# ret1 = obj.findall(str1)
# for i in ret1:
#     print(ret1)

#正则捕获
#导出教学计划
url = "http://www.w3.org/1999/xhtml"
##请求头
headers={
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0"
    ,"Cookie":"JSESSIONID=9650A5771C31C5F9AC0396F3DA8BA4F7; Path=/; name=value"
}
resp = requests.get(url,headers=headers)

content = resp.text
soup = BeautifulSoup(content,"html.parser")
#选取部分表格
print(soup.prettify())



















